import axios from 'axios'
import Moment from 'moment'
//请求方法封装

// 日期时间格式化
export function dateFormat (date) {
  var result = Moment(date).format('YYYY-MM-DD hh:mm:ss')
  return result
}

//get请求
export function get (url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.get("/edu"+url, {
      params:params
    })
    .then(res => {
      resolve(res)
    })
    .catch(error => {
      reject(error)
    })
  })
}

//   //post请求
export function post (url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.post("/edu"+url, params)
    .then(res => {
      resolve(res)
    })
    .catch(error => {
      reject(error)
    })
  })
}

//put请求
export function put (url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.put("/edu"+url, params)
    .then(res => {
      resolve(res)
    })
    .catch(error => {
      reject(error)
    })
  })
}

//delete请求
export function deleteR (url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.delete("/edu"+url, params)
    .then(res => {
      resolve(res)
    })
    .catch(error => {
      reject(error)
    })
  })
}

